
/**
 * 按长度裁剪字符串,超出部分用省略号代替 "..."
 * @param text 字符串
 * @param length 长度限制
 * @returns {string}
 */
export function ellipsisString(text = '',length){
    text = text || ''
    if(text.length >= length){
        return `${text.slice(0, length)}...`
    }
    return text
}

/**
 * 按长度生成带数字随机字符串
 * @param length 长度限制
 * @returns {string}
 */
const str = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
export function generateMixed(length) {
    let res = "";
     for(let i = 0; i < length ; i ++) {
         const id = Math.ceil(Math.random()*str.length-1);
         res += str[id];
     }
     return res;
}
